/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.admin.vo.parts.shop;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.core.tool.node.INode;
import javax.validation.constraints.NotBlank;
import java.util.ArrayList;
import java.util.List;

/**
 * 配件商城类目
 *
 * @author BladeX
 * @since 2024-07-26
 */
@Data
@ApiModel(value = "配件商城类目")
public class CategoryVO implements INode<CategoryVO> {
	private static final long serialVersionUID = 1L;
	/**
	 * 主键id
	 */
	@JsonSerialize(using = ToStringSerializer.class)
	@ApiModelProperty(value = "主键id")
	@TableId(value = "id", type = IdType.ASSIGN_ID)
	private Long id;

	/**
	 * 类目编号
	 */
	@ApiModelProperty(value = "类目编号")
	private String code;
	/**
	 * 类目名称
	 */
	@NotBlank(message = "类目名称不能为空")
	@ApiModelProperty(value = "类目名称")
	private String name;
	/**
	 * 父节点id
	 */
	@ApiModelProperty(value = "父节点id")
	private Long parentId;

	@ApiModelProperty(value = "父类目编号")
	private String parentCode;
	/**
	 * 父类目名称
	 */
	@ApiModelProperty(value = "父类目名称")
	private String parentName;
	/**
	 * 祖级类目主键
	 */
	@ApiModelProperty(value = "祖级类目主键")
	private String ancestors;
	/**
	 * 层级
	 */
	@ApiModelProperty(value = "层级")
	private Integer catLeave;
	/**
	 * 排序
	 */
	@ApiModelProperty(value = "排序")
	private Integer sort;
	/**
	 * 是否显示[0-不显示,1-显示]
	 */
	@ApiModelProperty(value = "是否显示[0-不显示,1-显示]")
	private Integer showStatus;

	/**
	 * 子孙节点
	 */
	@JsonInclude(JsonInclude.Include.NON_EMPTY)
	private List<CategoryVO> children;

	/**
	 * 是否有子孙节点
	 */
	@JsonInclude(JsonInclude.Include.NON_EMPTY)
	private Boolean hasChildren;

	@Override
	public List<CategoryVO> getChildren() {
		if (this.children == null) {
			this.children = new ArrayList<>();
		}
		return this.children;
	}

}
